<html>
<head><meta charset="utf-8"><title>D98145 · t-compiler/wg-llvm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/index.html">t-compiler/wg-llvm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/D98145.html">D98145</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="229215949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/D98145/near/229215949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/D98145.html#229215949">(Mar 07 2021 at 20:35)</a>:</h4>
<p><span class="user-mention" data-user-id="133224">@Nikita Popov</span> Reading <a href="https://reviews.llvm.org/D98145">https://reviews.llvm.org/D98145</a>, I'm not quite sure why the <code>I-&gt;hasOneUse()</code> is returning <code>true</code> in the test case. Depending on how I count, I see either 0 or 2. Let me explain, so the relevant excerpt of the dag is:</p>
<div class="codehilite"><pre><span></span><code>  %8:gr64 = COPY $rdx
  MOV64mr %1:gr64, 1, $noreg, 0, $noreg, killed %8:gr64 :: (store 8 into %ir.p)
  %2:gr64 = IMPLICIT_DEF
  ADJCALLSTACKDOWN64 0, 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp
  $rdi = COPY %2:gr64
  $rsi = COPY %8:gr64
  CALL64pcrel32 target-flags(x86-plt) @use, &lt;regmask $bh $bl $bp $bph $bpl $bx $ebp $ebx $hbp $hbx $rbp $rbx $r12 $r13 $r14 $r15 $r12b $r13b $r14b $r15b $r12bh $r13bh $r14bh $r15bh $r12d $r13d $r14d $r15d $r12w $r13w $r14w $r15w $r12wh and 3 more...&gt;, implicit $rsp, implicit $ssp, implicit $rdi, implicit $rsi
</code></pre></div>
<p>If the <code>hasTrivialKill</code>/<code>hasOneUse</code> is invoked during construction of <code>MOV64mr</code> instruction and the overall DAG is unknown, then isn't the number of uses of the <code>%8</code> register 0? Otherwise if the <code>hasTrivialKill</code>/<code>hasOneUSe</code> is invoked when the DAG has the shape, then <code>%8</code> will have 2 uses, right?</p>



<a name="229216049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/D98145/near/229216049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/D98145.html#229216049">(Mar 07 2021 at 20:36)</a>:</h4>
<p>The hasOneUse() refers to an IR instruction, not an MachineInstr</p>



<a name="229216084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/D98145/near/229216084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/D98145.html#229216084">(Mar 07 2021 at 20:38)</a>:</h4>
<p>In this case the extractvalue, which has only one use</p>



<a name="229216155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/D98145/near/229216155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/D98145.html#229216155">(Mar 07 2021 at 20:39)</a>:</h4>
<p>Oh!</p>



<a name="229216181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/D98145/near/229216181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/D98145.html#229216181">(Mar 07 2021 at 20:39)</a>:</h4>
<p>So it'd have been fine if we didn't extractvalue exactly the same thing from <code>%struct</code> twice.</p>



<a name="229216243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/D98145/near/229216243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/D98145.html#229216243">(Mar 07 2021 at 20:40)</a>:</h4>
<p>In that case, it seems like this is prone to same kind of problem with many different instructions, intuitively thinking.</p>



<a name="229217171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/D98145/near/229217171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/D98145.html#229217171">(Mar 07 2021 at 20:56)</a>:</h4>
<p>Yeah, that code is definitely fragile. It needs to be careful to exclude anything that might be recognized as a no-op.</p>



<a name="229217313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/D98145/near/229217313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/D98145.html#229217313">(Mar 07 2021 at 20:58)</a>:</h4>
<p>I'm wondering whether we should have a CI job with EXPENSIVE_CHECKS, might have caught this. Most likely it would be too slow though.</p>



<a name="229218626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/D98145/near/229218626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/D98145.html#229218626">(Mar 07 2021 at 21:18)</a>:</h4>
<p>Hm, is there a way to turn on all of the <code>-verify</code> flags with a single flag?</p>



<a name="229295618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/D98145/near/229295618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/D98145.html#229295618">(Mar 08 2021 at 13:14)</a>:</h4>
<p>Trying to do an expensive_checks build... First failure is that it doesn't build at all, which is fixed by <a href="https://reviews.llvm.org/D98167">https://reviews.llvm.org/D98167</a>. Then std build fails with "Pass modifies its input and doesn't report it: MemCpy Optimization"</p>



<a name="229570818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/D98145/near/229570818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/D98145.html#229570818">(Mar 09 2021 at 22:51)</a>:</h4>
<p>I've submitted a followup patch <a href="https://reviews.llvm.org/D98294">https://reviews.llvm.org/D98294</a> to <em>ehem</em> kill kills with fire.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>